package controller

import (
	"github.com/gin-gonic/gin"
	"src/req"
	"src/response"
	"src/services"
	"src/utils"
)

/*
@date : 2024/8/28 11:19
@author : mie
@desc: pancake swap v2 transaction
*/

func ApiSwapTransactionRoute(api *gin.RouterGroup) {
	api.POST("/swap/v2/transaction", func(context *gin.Context) {
		var req req.SwapTransactionReq
		err := context.ShouldBindJSON(&req)
		if err != nil {
			response.Fail(context, 500, utils.ValidateMsg(req, err))
			return
		}
		er := services.TransactionV2(&req)
		if err != nil {
			response.XFail(context, er.Error())
			return
		}
		response.XSuccess(context)
	})
}
